<?php

function affdetails($donnees, $etapes, $images) {
    ?>
    <h2>
        <?php echo $donnees['nom']; ?>
    </h2>
    <div class = "underline">
        <h3>Données techniques</h3>
        <p class="description_avion">
            <?php echo $donnees['description']; ?>    
        </p>
        <p>
            <span class="label">Stabilité : </span>
            <?php
            for ($i = 0; $i < $donnees['stabilite']; $i++) {
                ?>
                <img src = "/images/etoiles/star_on.png" alt = 1></img>
                <?php
            }
            for ($i = 0; $i < 5 - $donnees['stabilite']; $i++) {
                ?>
                <img src = "/images/etoiles/star_off.png" alt = 1></img>
                <?php
            }
            ?><br/>
            <span class="label">Difficulté : </span>
            <?php
            for ($i = 0; $i < $donnees['difficulte']; $i++) {
                ?>
                <img src = "/images/etoiles/star_on.png" alt = 1></img>
                <?php
            }
            for ($i = 0; $i < 5 - $donnees['difficulte']; $i++) {
                ?>
                <img src = "/images/etoiles/star_off.png" alt = 1></img>
                <?php
            }
            ?><br/>
            <span class="label">Stabilité au tangage : </span>
            <?php
            for ($i = 0; $i < $donnees['stab_tang']; $i++) {
                ?>
                <img src = "/images/etoiles/star_on.png" alt = 1></img>
                <?php
            }
            for ($i = 0; $i < 5 - $donnees['stab_tang']; $i++) {
                ?>
                <img src = "/images/etoiles/star_off.png" alt = 1></img>
                <?php
            }
            ?><br/>
            <span class="label">Stabilité au roulis : </span>
            <?php
            for ($i = 0; $i < $donnees['stab_roul']; $i++) {
                ?>
                <img src = "/images/etoiles/star_on.png" alt = 1></img>
                <?php
            }
            for ($i = 0; $i < 5 - $donnees['stab_roul']; $i++) {
                ?>
                <img src = "/images/etoiles/star_off.png" alt = 1></img>
                <?php
            }
            ?><br/>
            <span class="label">Vitesse d'évolution : </span>
            <?php
            echo $donnees['vitesse'];
            ?> <br/>
            <span class="label">Vitesse de décrochage : </span>
            <?php
            echo $donnees['decrochage'];
            ?>
        </p>
    </div>
    <div class="underline">
        <h3>Construction</h3>
        <?php
        for ($i = 1; $donnees_etape = $etapes->fetch(); $i++) {
            $nb_images = 0;
            for ($j = 0; $donnees_images = $images->fetch(); $j++) {
                if ($donnees_images['no_etape'] == $i) {
                    $nb_images++;
                    $addr_image[$nb_images] = $donnees_images['adresse'];
                }
            }
            ?>
            <div class="etapes" >
                <div class="contenu">
                    <p>
                        <span class="no_etape"><?php echo $donnees_etape['numero'] . ' - '; ?></span><?php echo $donnees_etape['contenu']; ?>
                    </p>
                </div>
                <div class="image" id="etape_<?php echo $i; ?>">
                    <table>
                        <tr>
                            <td rowspan="<?php echo $nb_images; ?>"><img id="img_princ_<?php echo $i; ?>" src="<?php echo $addr_image[1]; ?>" height="320"/></td>
                            <?php
                            if ($nb_images > 1) {
                                ?>
                                <td><img src="<?php echo $addr_image[1]; ?>" height="<?php echo 320 / $nb_images; ?>" class="thumb_set" onClick="$('#etape_<?php echo $i; ?> .thumb_set').attr('class', 'thumb');document.getElementById('img_princ_<?php echo $i; ?>').src='<?php echo $addr_image[1] ?>';$(this).attr('class', 'thumb_set');" onMouseOver="$('#etape_<?php echo $i; ?> .thumb_set').attr('class', 'thumb');document.getElementById('img_princ_<?php echo $i; ?>').src='<?php echo $addr_image[1] ?>';$(this).attr('class', 'thumb_set');"/></td>
                                <?php
                            }
                            ?>
                        </tr>
                        <?php
                        if ($nb_images > 1) {
                            for ($k = 2; $k <= $nb_images; $k++) {
                                ?>					
                                <tr>
                                    <td><img src="<?php echo $addr_image[$k] ?>" class="thumb" height="<?php echo 320 / $nb_images; ?>" onClick="$('#etape_<?php echo $i; ?> .thumb_set').attr('class', 'thumb');document.getElementById('img_princ_<?php echo $i; ?>').src='<?php echo $addr_image[$k] ?>';$(this).attr('class', 'thumb_set');" onMouseOver="$('#etape_<?php echo $i; ?> .thumb_set').attr('class', 'thumb');document.getElementById('img_princ_<?php echo $i; ?>').src='<?php echo $addr_image[$k] ?>';$(this).attr('class', 'thumb_set');"/></td>
                                </tr>
                                <?php
                            }
                        }
                        ?>						
                    </table>
                </div>
            </div>
            <?php
            $images->closeCursor();
            $images->execute(array($_GET["id"]));
            $addr_image = array();
        }
        ?>
    </div>
    <?php
}
?>
